const http = require('../../utils/http.js'); 
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navindex: 0,
    show: true,
    list1Content: [],
    contindex: 1,
    shopdata: '',
    shop_name: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    http.postRequest('/mini/v1/work/work_shop',{},res=>{
      for(let i in res.data.data) {
        if(res.data.data[i].exit_time) {
          res.data.data[i].time = http.transTime(res.data.data[i].exit_time)
        }
      }
      this.setData({
        shopdata: res.data,
        shop_name: wx.getStorageSync('shop_name')
      })
    })
  },
  show() {
    this.setData({
      show: false
    })
  },
  hide() {
    this.setData({
      show: true
    })
  },
  hide1() {
    this.setData({
      show: true
    })
    let status1 = [];
    let list1Content = this.data.list1Content;
    if(list1Content[0]) status1.push(1)
    if(list1Content[1]) status1.push(2)
    if(list1Content[2]) status1.push(3)
    http.postRequest('/mini/v1/work/work_shop',{status: status1},res=> {
      this.setData({
        shopdata: res.data
      })
    })
  },
  navbind(e) {
    let index = e.currentTarget.dataset.index;
    this.setData({
      navindex: index
    })
  },
  onstore(e) {
    let index = e.currentTarget.dataset.index;
    let list1Content = this.data.list1Content;
    list1Content[index] = !this.data.list1Content[index];
    this.setData({
      list1Content: list1Content
    })
  },
  contindex(e) {
    let index = e.currentTarget.dataset.index;
    this.setData({
      contindex: index
    })
  }
})